package com.minelx.util.date;

import java.util.Calendar;

public enum ClockUnit {

	MONTH(Calendar.MONTH) {
		@Override
		public void set(Calendar target, int at) {
			target.set(Calendar.MONTH, at - 1);
		}
	},

	DAY(Calendar.DAY_OF_MONTH) {
		@Override
		public void set(Calendar target, int at) {
			target.set(Calendar.DAY_OF_MONTH, at);
		}
	};

	private final int calendarConstant;

	ClockUnit(int calendarConstant) {
		this.calendarConstant = calendarConstant;
	}

	public abstract void set(Calendar target, int at);

	public void add(Calendar target, int amount) {
		target.add(calendarConstant, amount);
	}
}
